// Copyright 2019-2021 The Inspektor Gadget authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

option go_package = "github.com/inspektor-gadget/inspektor-gadget/pkg/gadgettracermanager";

package gadgettracermanager;

service GadgetTracerManager {
  // Methods called via kubectl-exec
  rpc ReceiveStream(TracerID) returns (stream StreamData) {}

  // Methods called by OCI Hooks
  rpc AddContainer(ContainerDefinition) returns (AddContainerResponse) {}
  rpc RemoveContainer(ContainerDefinition) returns (RemoveContainerResponse) {}

  // Methods called for debugging
  rpc DumpState(DumpStateRequest) returns (Dump) {}
}

message Label {
  string key = 1;
  string value = 2;
}

message AddContainerResponse {
  string debug = 1;
}

message RemoveContainerResponse {
  string debug = 1;
}

message TracerID {
  string id = 1;
}

message StreamData {
  string line = 1;
}

message OwnerReference {
  string apiversion = 1;
  string kind = 2;
  string name = 3;
  string uid = 4;
}

message ContainerDefinition {
  string id = 1;
  uint32 pid = 2;
  string oci_config = 3;

  // NRI and OCI hooks don't give the OCI config but give pod details
  string namespace = 4;
  string podname = 5;
  string name = 6;
  repeated Label labels = 7;
  // Some hooks do not have information about the pod labels
  bool labels_set = 8;
}

message DumpStateRequest {
}

message Dump {
  string containers = 1;
  string traces = 2;
  string stacks = 3;
}
